/*
 * author binhbt
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
                        $(document).ready(function(){
                                sortable_setup();
                                drag_drop_sertup();
                                //widget_setup();
                            function sortable_setup(){
                                $('#column1').sortable({opacity: 0.6, cursor: 'move', update: function(){}});
                                $('#column2').sortable({opacity: 0.6, cursor: 'move', update: function(){}});
                                $('#sidebar').sortable({opacity: 0.6, cursor: 'move', update: function(){}});
                                $('.fullwidget').sortable({opacity: 0.6, cursor: 'move', update: function(){}});
                                $('.box').sortable({opacity: 0.6, cursor: 'move', update: function(){}});
                                $('#footer').sortable({opacity: 0.6, cursor: 'move', update: function(){}});
				$('#pageright').sortable({opacity: 0.6, cursor: 'move', update: function(){}});
                            }
                            function drag_drop_sertup(){
                                //change color when selected
                                //for post box
                                $('div.postbox h1').bind('mouseenter',function() {
                                   $(this).parent().addClass('onbox');
                                });
                                $('div.postbox h1').bind('mouseleave',function() {
                                   $(this).parent().removeClass('onbox');
                                });
                                //for footer
                                $('#footer h3').bind('mouseenter',function() {
                                   $(this).parent().addClass('onbox');
                                });
                                $('#footer h3').bind('mouseleave',function() {
                                   $(this).parent().removeClass('onbox');
                                });

                                //for left sidebar
                                $('.leftsidebar h3').bind('mouseenter',function() {
                                   $(this).parent().addClass('onbox');
                                });
                                $('.leftsidebar h3').bind('mouseleave',function() {
                                   $(this).parent().removeClass('onbox');
                                });

                                //for right sidebar
                                $('.sidebar h3').bind('mouseenter',function() {
                                   $(this).parent().addClass('onbox');
                                });
                                $('.sidebar h3').bind('mouseleave',function() {
                                   $(this).parent().removeClass('onbox');
                                });
								//for page right
								
                                $('#pageright h3').bind('mouseenter',function() {
                                   $(this).parent().addClass('onbox');
                                });
                                $('#pageright h3').bind('mouseleave',function() {
                                   $(this).parent().removeClass('onbox');
                                });

                            }
                            function widget_setup(){
                                var bar =
                                '<div class="utils">'
				+'<p class="collapse">'
				+'<a title="Minimise the section" rel="nofollow" class="expanded" id="_collapse" href="javascript:minimize_widget(this)">'
                                +'<img height="11" width="11" alt="Minimise the section" src="http://static.bbc.co.uk/wwhomepage/img/expanded.png">'
                                +'</a>'
                                +'</p>'
				+'<p class="remove">'
                                +'<a rel="nofollow" title="Remove the section" id="_remove" href="javascript::silent()">'
				+'<img height="22" width="15" alt="Remove the section" src="http://static.bbc.co.uk/wwhomepage/img/x.gif">'
                                +'</a>'
                                +'</p>'
                                +'</div>';
                            var expanded=
                                $('<p class="collapse">'
				+'<a title="Maximise the section" rel="nofollow" class="expanded" id="_expanded" href="javascript::silent()">'
                                +'<img height="11" width="11" alt="Maximise the section" src="http://static.bbc.co.uk/wwhomepage/img/collapsed.png">'
                                +'</a>'
                                +'</p>');
                            var collapsed=
                                $('<p class="collapse">'
				+'<a title="Minimise the section" rel="nofollow" class="expanded" id="_collapse" href="javascript::silent()">'
                                +'<img height="11" width="11" alt="Minimise the section" src="http://static.bbc.co.uk/wwhomepage/img/expanded.png">'
                                +'</a>'
                                +'</p>');
                           collapsed.find('#_collapsed').bind('click', function(){
                                //alert('bbb');
                                    $(this).parent().parent().append(expanded);
                                    $(this).remove();
                                });
                            expanded.find('#_expanded').bind('click', function(){
                                //alert('aa');
                                    $(this).parent().parent().append(collapsed);
                                    $(this).remove();
                                });
                                //for post box
                                $('div.postbox h1').parent().addClass('module');
                                $('div.postbox h1').parent().append(bar);
                                $("#_collapse").bind('click', function(){
                                    //alert($(this).html());
                                    $(this).parent().parent().append(expanded);
                                    $(this).remove();
                                });

                            }
                   });
                   //javascript not jq
